package com.example.webtest.controller.consistencyController;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Objects;
@Controller
public class logincontroller {
	private static  String name="zjh";
	private static String passwords="111111";
	@PostMapping("/login")
	public String login(String username, String password, HttpServletRequest request){
	/*	String authorization = request.getHeader("Authorization");

		if(!authorization.equals("Beerer qazwsxedc")){
			return "可能是伪造请求";
		}*/

		if (!Objects.equals(username,name)){
			return "账户错误";
		}
		if(!Objects.equals(password,passwords)){
			return "密码错误";
		}
		System.out.println("账号:"+username+" 密码:"+password);
		return "success";
	}

	@PostMapping("/login2")
	public String login2(String username, String password, HttpServletRequest request){
	/*	String authorization = request.getHeader("Authorization");

		if(!authorization.equals("Beerer qazwsxedc")){
			return "可能是伪造请求";
		}*/

		if (!Objects.equals(username,name)){
			System.out.println("账号错误");
		}
		if(!Objects.equals(password,passwords)){
			System.out.println("密码错误");
		}
		System.out.println("单点登录");
		return "home";
	}






	@RequestMapping("/map")
	public String dis(){
		return "sso";
	}

	@RequestMapping("/home")
	public String home(){
		return "home";
	}
}
